﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.ADF.BaseClasses;
using PlanningGIS.Framework;
using PlanningGIS.ArcGIS;
using PlanningGIS.Win.Controls;

namespace PlanningGIS.Analysis
{
    /// <summary>
    /// Dem按高程统计面积按钮类
    /// 作者：
    /// 编写日期：2009-06-17
    /// </summary>
    public class StaDemAreaCommand : BaseCommand 
    {
        /// <summary>
        /// 
        /// </summary>
        IApplication m_Application = null;
        /// <summary>
        /// 
        /// </summary>
        public StaDemAreaCommand()
        {
            base.m_caption = "DEM分析";
            base.m_toolTip = base.m_caption;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hook"></param>
        public override void OnCreate(object hook)
        {
            if (m_Application == null)
            {
                m_Application = hook as IApplication;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public override void OnClick()
        {
            if (m_Application == null)
                return;
            if ((m_Application as IFramework).IsMapCtrlactive)
            {
                IMap pMap = (m_Application as IFramework).MapControl.Map;
                List<IRasterLayer> pLyrnameArray = MapHelper.GetAllLayer<IRasterLayer>(pMap);
                if (pLyrnameArray.Count == 0)
                {
                    MsgHelper.ShowInfomationMsgbox("请在当前地图加载栅格DEM数据！");
                }
                else
                {
                    FrmDemArea frmQuery = FrmDemArea.CreateNewForm();
                    frmQuery.Application = m_Application;
                    frmQuery.Show((m_Application as IFramework).MdiForm);
                }
            }
        }

        //public override int Bitmap
        //{
        //    get
        //    {
        //        string bitmapResourceName = "PlanningGIS.Analysis.Res." + this.GetType().Name + ".png";
        //        return new Bitmap(GetType().Assembly.GetManifestResourceStream(bitmapResourceName)).GetHbitmap().ToInt32();
        //    }
        //}
    }

}
